package xworker.gluon.glisten.visual;

import com.gluonhq.charm.glisten.visual.MaterialDesignIcon;
import org.xmeta.ActionContext;
import org.xmeta.Thing;

public class MaterialDesignIconActions {
    public static Object create(ActionContext actionContext){
        Thing self = actionContext.getObject("self");

        MaterialDesignIcon icon = MaterialDesignIcon.valueOf(self.getString("icon"));

        Object node;
        if("Graphic".equals(self.getString("instance"))){
            node = icon.graphic();
        }else{
            node = icon.button();
            actionContext.peek().put("parent", node);
            for(Thing child : self.getChilds()){
                child.doAction("create", actionContext);
            }
        }

        actionContext.g().put(self.getMetadata().getName(), node);
        return node;
    }
}
